Release 10.1A: OpenEdge Data Management:
DataServer for ORACLE
Defining a view to use as a buffer
As an alternative to using the buffer
proc–text–bufferdefined by Progress, you can define a view in the data source that can serve as a buffer allowing you to retrieve database results in their original data types. However, keep in mind that using views creates a database dependency beyond the stored procedure itself.Technique to define a view to use as a buffer
While a stored procedure can include multiple SQL statements, a buffer that you define contains the format of only a single result set. You need to define multiple views to accommodate multiple result sets.
![]()
To define a buffer:
- Define a view in the ORACLE data source with the following characteristics:
- The naming convention
BUFFER_buffername.- The same number of columns and data types that the stored procedure returns in the result set.
- The columns in the order that the stored procedure returns them.
For example, to return two columns with two types of values, an integer and a character string, use an SQL utility to define the following view in the data source:
Notice that these views are defined to ensure that they never return any results. This helps to indicate that the purpose of the view is its buffer content and not its SQL capabilities. It is not necessary to define views that you will use as buffers this way, but it does allow you to distinguish quickly between views and buffers.
- Update your schema image using the Update/Add Table Definitions DataServer utility. The utility adds the view to the list of accessible objects in the schema holder. The DataServer defines the view as a buffer that Progress can use. See the "Updating a schema image" section for instructions on using this utility.
Assessing result sets obtained by defining a view as buffer technique
The buffer in the previous procedure defines two returned values for a stored procedure—an
INTEGERand aCHARACTERvalue—in that order. If the data types do not match those returned by the stored procedure, the procedure returns more than two values, or returns the values in a different order than you specified, you receive a run-time error.The easiest way to create a buffer that accepts data from stored procedures is to use the text of the SQL
SELECTstatement from the stored procedure. This ensures that you define your data types correctly and in the correct order.Examples based on views created in the data source
The examples in this section do not use the supplied
proc-text-bufferbuffer. Instead, they show how to define formatted buffers by creating views in the data source, using the following syntax:
The following two examples show the views created in your ORACLE data source that you can use as buffers to store the results from the stored procedure
pcust:
Example 3–7 runs the
Note: The following example is not intended to illustrate the use of the previous syntax.send-sql-statementoption twice; procedure handles (through thePROC-HANDLEfunction) identify the different results from the ORACLE database.
Example 3–7: Running the send-sql-statement option twiceIf you use more than one
send-sql-statementat a time to sendSELECTstatements, you must explicitly define procedure handles for each.Example 3–8 is a two-part example. The first code shows a stored procedure. The second code shows the Progress 4GL procedure that is associated with the stored procedure.
The following 4GL procedure code assumes that the
pcust_bufferandporder_bufferexist in the schema and that they match the result-sets schema.
Example 3–8: Illustrating how a stored procedure returns multiple result sets and how to access the result sets using cursor arguments and buffersAs Example 3–8 shows, the stored procedure
pcustorderreturns multiple result-sets. The second code box shows the procedure used to access the result sets; it uses cursor arguments and buffers.Because two different buffers have been defined, the returned values maintain their data types instead of being converted to character strings and stored in the Progress-defined buffer
proc–text–buffer. You can then use the returned values in calculations without first converting them back to their original data types. In addition, the two separate buffers make your output look cleaner, allowing the 4GL to build a new default frame for the two different types of output. Reading your results into an explicitly defined buffer also allows you to manipulate the data just as you would manipulate data from an OpenEdge database; for example, with Frame phrases andFORMstatements.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |